<?php
class MoreSearchForm extends Form{
	private $cachefile='MoreSearch';
	function MoreSearchForm(){
		Form::Form('MoreSearchForm');					
	}	
		
	function draw(){				
		$set_tag_search = "";
		$url_root = WEB_ROOT.'search?keywords=';
		
		if(StaticCache::notExistCache($this->cachefile,300)){
			StaticCache::startCache();
			global $display;
			$this->beginForm();
			$set_tag_search = "";
				
			$color_max_rand = array(0=>'color:#F60',
									1=>'color:#09C',
									2=>'color:#090',
									3=>'color:#666',
								);
			$count_color_max_rand = count($color_max_rand);									
			$re	= DB::query('SELECT id, keywords, hit FROM tag_search  ORDER BY rand() LIMIT 500');
			if($re){
				while ($item=mysql_fetch_assoc($re)){					
					$font_size = 12; //mac dinh font =12px
					$max_font = 25;// font max = 25px
					$font_color = ""; // color when max font
					$font_size += round($item["hit"]/5000); 					
					if($font_size>$max_font){
						$font_size = $max_font;												
					}
					$font_color = $color_max_rand[rand(0,$count_color_max_rand-1)];
					$set_tag_search .= ($set_tag_search?', ':'').'<a target="_blank" href="'.$url_root.urlencode($item["keywords"]).'&id='.$item["id"].'"><span style="font-size:'.$font_size.'px;'.$font_color.'">'.$item["keywords"].'</span></a>';
				}
			}
			$display->add('items', $set_tag_search);
			$display->output('MoreSearch');
			$this->endForm();
			StaticCache::endCache();
		}
	}
}
?>